package es.mgil.linternas;

import es.mgil.linternas.R;

import android.app.Activity;
import android.os.Bundle;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnTouchListener;
import android.view.Window;
import android.view.WindowManager;
import android.widget.RelativeLayout;

public class LinternaRoja extends Activity implements OnTouchListener {
	private RelativeLayout fondo;
	private int colorNegro = 0xff000000;
	private int colorRojo = 0xffff0000;

	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);

		requestWindowFeature(Window.FEATURE_NO_TITLE);
		getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
				WindowManager.LayoutParams.FLAG_FULLSCREEN);
		setContentView(R.layout.linterna_roja);

		fondo = (RelativeLayout) findViewById(R.id.fondoRojo);
		fondo.setBackgroundColor(colorRojo);
		fondo.setOnTouchListener(this);
	}

	@Override
	public boolean onTouch(View v, MotionEvent event) {
		switch (event.getAction()) {
		case MotionEvent.ACTION_DOWN:
		case MotionEvent.ACTION_MOVE:
		case MotionEvent.ACTION_CANCEL:
			fondo.setBackgroundColor(colorNegro);
			break;
		case MotionEvent.ACTION_UP:
			fondo.setBackgroundColor(colorRojo);
			break;
		}

		return true;
	}
}
